package someTestExcemple.huaweiOd.string;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//华为OD机试 - 字符串统计（Java 2024 C卷 100分）
//https://blog.csdn.net/guorui_java/article/details/136493230
public class CountString {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("@");
        sc.close();
        //没有已使用字符集
        if(str.length == 1) {
            System.out.println(str[0]);
        } else {
            //所有字符 --字符--数量
           Map<String,Integer> allMap = new HashMap<>();
           String[] allSet = str[0].split(",");
           String[] usedSet = str[1].split(",");
           for(int i=0;i<allSet.length;i++) {
               String[] s =allSet[i].split(":");
               allMap.put(s[0],Integer.parseInt(s[1]));
           }
           for(int i=0;i<usedSet.length;i++) {
               String[] s = usedSet[i].split(":");
               if(allMap.containsKey(s[0])) {
                   int after = allMap.get(s[0]) -Integer.parseInt(s[1]);
                   if(after==0) {
                       allMap.remove(s[0]);
                   } else {
                       allMap.put(s[0],after);
                   }
               }
           }
           if(!allMap.isEmpty()) {
               StringBuilder result = new StringBuilder();
               allMap.keySet().stream().forEach(a->{
                  result.append( a+":"+allMap.get(a)+",");
               });
               result.deleteCharAt(result.length()-1);
               System.out.println(result.toString());
           }
        }
    }
}
